home *** CD-ROM | disk | FTP | other *** search
- Path: inforamp.net!ts9-03
- From: rmorin@inforamp.net (Randy Charles Morin)
- Newsgroups: comp.lang.c++
- Subject: Re: Save whole structures and reloading
- Date: Thu, 07 Mar 96 06:10:49 GMT
- Organization: MiddleWorld SoftWare
- Message-ID: <4hlul3$6jg@sam.inforamp.net>
- References: <4hinsi$34@ornews.intel.com>
- NNTP-Posting-Host: ts9-03.tor.inforamp.net
- X-Newsreader: News Xpress Version 1.0 Beta #4
-
- In article <4hinsi$34@ornews.intel.com>,
- ivan_m_hendricks@ccm2.hf.intel.com (Ivan Hendricks) wrote:
- >Is there a way to save a struct or class so that when I reread it from
- >a file, it will be in the same member variable/types that it came out
- >of? Can someone please give me an example.
-
- What you want is a persistent object? Examples:
-
- const char filename[]="C:\\HELLO.DAT"
- class myclass
- {
- int a,b;
- public:
- myclass()
- {
- ifpstream is(filename);
- is >> a >> b;
- };
- ~myclass()
- {
- ofpstream os(filename);
- os << a << b;
- };
- };
-
- Of course, this is a simplistic example.
-
- Agrivar
-